package com.java8.time.api;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

/**
 * <p>Description: [Java 8计算一年前或一年后的日期]</p>
 * Created on 2020/2/21
 *
 * @author <a href="mailto: 819712047@qq.com">谢振东 </a>
 * @version 1.0
 */
public class Demo09 {

    /**
     * 利用minus()方法计算一年前的日期
     */
    public static void master() {
        System.out.println("-----------------Demo09.master()-----------------");
        LocalDate today = LocalDate.now();

        LocalDate previousYear = today.minus(1, ChronoUnit.YEARS);
        System.out.println("一年前的日期 : " + previousYear);

        LocalDate nextYear = today.plus(1, ChronoUnit.YEARS);
        System.out.println("一年后的日期:" + nextYear);
    }
}
